home *** CD-ROM | disk | FTP | other *** search
- /* Atari .ST diskimages list */
- /* Fabrizio "Lanch" Bartoloni */
- /* lanch@tiscalinet.it */
- /*
- Thanks to: Alfonso "Alfie" Ranieri
- Emiliano "Skywalk3r" Esposito
- Alessandro "Crusher" Gatti
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- static char verstr[] = "$VER: STList 1.4 (05.11.00)";
-
- int main(int argc, char **argv)
- {
- char *progname = argv[0];
- char *destfile = argv[2];
- FILE *fp, *fd;
- char *diskimage = argv[1];
- char buf[] = " "; /* filenames are 12 characters long */
- /* and they fill the whole space */
- /* then 4 empty + 16 trash and repeat */
-
-
- if (argc != 3)
- {
- fprintf(stderr, " Usage: %s diskimage.st diskcontent.txt \n", progname);
- fprintf(stderr, " © 2000 Fabrizio 'Lanch' Bartoloni \n");
- fprintf(stderr, " lanch@tiscalinet.it \n");
- exit(1);
- }
-
- if (fp = fopen(diskimage,"rb")) {
- /* We go to 0x0E00, here is located the beginning */
- /* of the directory listing, else it must be at 0x1600 */
- long offset;
- int ascii;
- int ascii2;
- long increase;
-
-
- offset = 0x0E00L;
- fseek(fp,offset,0);
- ascii = fgetc(fp);
- if ((ascii > 49)&&(ascii < 123))
-
- {
- offset = 0x0DE0L; /* we went one step before for the loop sake */
- }
-
- else
-
- {
- offset = 0x15E0L;
- fseek(fp,offset,0);
- ascii2 = fgetc(fp);
- if ((ascii2 < 49)|(ascii2 > 122))
- {
- fprintf(stderr, " %s ST diskimage is not DOS \n", diskimage);
- exit(1);
- }
- }
- increase = 32L;
- if (fd = fopen(destfile, "w")) {
- fprintf(fd, " Listing of %s :\n\n", diskimage);
- while (*buf != 0) { /* until we don't find an empty buffer */
- offset = offset + increase;
- fseek(fp,offset,0);
- fgets(buf, sizeof(buf), fp);
- fprintf(fd," %s\n", buf);
- } /* endwhile */
- fprintf(fd,"\n End of listing.\n");
- exit(0);
- } /* endif fopen write */
- else
- {
- fprintf(stderr," Unable to create %s\n", destfile);
- exit(1);
- }
- } /* endif fopen read */
- else
- {
- fprintf(stderr, "Unable to open file: %s\n", diskimage);
- exit(1);
- }
- fclose(fd);
- fclose(fp);
- return(0);
- }
-